package com.idea.cery.springboot1.service.impl;

import com.idea.cery.springboot1.mapper.MybatisDao;
import com.idea.cery.springboot1.entity.User;
import com.idea.cery.springboot1.service.MybatisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MybatisServiceImpl implements MybatisService {
    @Autowired
    MybatisDao mybatisDao;

    @Override
    public String add(User user) {
        String str = "添加失败！";
        int re = mybatisDao.add(user);
        if (re > 0) {
            str = "添加成功！";
        }
        return str;
    }

    @Override
    public String del(String id) {
        String str = "删除失败！";
        int re = mybatisDao.del(id);
        if (re > 0) {
            str = "删除成功！";
        }
        return str;
    }

    @Override
    public String upd(User user) {
        String str = "更新失败！";
        int re = mybatisDao.upd(user);
        if (re > 0) {
            str = "更新成功！";
        }
        return str;
    }

    @Override
    public List<User> list() {

        return mybatisDao.list();
    }
}
